import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'
import Login from '@/components/Login.vue'
import HomeList from '@/components/HomeList.vue'
import YingyeList from '@/components/yingyeting/YingyeList.vue'
import Product from '@/components/yingyeting/Product.vue'
import ProductDetail from '@/components/yingyeting/ProductDetail.vue'
import Cart from '@/components/shoppingcart/Cart.vue'
import MyMove from "@/components/mymove/MyMove.vue";
import JiFenList from '@/components/jifen/JiFenList.vue'
import Coupon from '@/components/jifen/Coupon.vue'
import MyCoupon from '@/components/jifen/MyCoupon.vue'
import Recharge from "@/components/mymove/Recharge.vue";
import MyMoveView from "@/components/mymove/MyMoveView.vue";
import Confirm from "@/components/mymove/Confirm.vue";
import MyInvoice from "@/components/mymove/MyInvoice.vue";
import SkuDetail from '@/components/jifen/SkuDetail.vue'
import MyJiFenView from '@/components/jifen/MyJiFenView.vue'
import JiFenRecharge from '@/components/jifen/JiFenRecharge.vue'
import SkuPay from '@/components/shoppingcart/SkuPay.vue'
import FuwuIndex from '@/components/fuwu/FuwuIndex.vue'
import SkuPayForJifen from '@/components/jifen/SkuPayForJifen.vue'
import JifenConfirm from '@/components/jifen/JifenConfirm.vue'
import NewKill from '@/components/jifen/kill/NewKill.vue'
import ShowComment from '@/components/fuwu/ShowComment.vue'
import MyBuySku from '@/components/fuwu/MyBuySku.vue'
import MySkuComment from '@/components/fuwu/MySkuComment.vue'
import ReturnSku from '@/components/fuwu/ReturnSku.vue'
import ProductDetailOne from '@/components/yingyeting/ProductDetailOne.vue'
import test from '@/components/test.vue'
import OrderPay from '@/components/mymove/OrderPay.vue'

Vue.use(VueRouter)

const routerPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(err => err);
}

const routes = [
  { component: Login, path: '/' },
  {
    path: '/home',
    component: HomeView,
    children: [
      { path: '/', redirect: '/homeList' },
      { path: '/homeList', component: HomeList },
      { path: '/yingyeList', component: YingyeList },
      {
        path: "/myMoveView",
        component: MyMoveView,
        children: [
          { path: "/", redirect: "/myMove" },
          { path: "/myMove", component: MyMove },
          { path: "/recharge", component: Recharge },
          { path: "/confirm", component: Confirm },
          { path: "/myInvoice", component: MyInvoice },
          { path: "/orderPay", component: OrderPay },
        ],
      },
      { path: "/product", component: Product },
      { path: "/productDetail", component: ProductDetail },
      { path: "/cart", component: Cart },
      {
        path: "/fuwuIndex", component: FuwuIndex,
        children: [
          { path: "/", redirect: "/myBuySku" },
          { path: "/myBuySku", component: MyBuySku },
          { path: "/showComment", component: ShowComment },
          { path: "/mySkuComment", component: MySkuComment },
          { path: "/returnSku", component: ReturnSku },
        ]
      },
      { path: '/skuPay', component: SkuPay },
      {
        path: '/myJiFenView',
        component: MyJiFenView,
        children:[
         { path: "/", redirect: "/jiFenList" },
         { path: '/jiFenList', component: JiFenList },
         { path: '/coupon', component: Coupon },
         { path: '/skuDetail', component: SkuDetail },
         { path: '/myCoupon', component: MyCoupon },
         { path: '/jiFenRecharge', component: JiFenRecharge },
         { path: '/jifenConfirm', component: JifenConfirm },
         { path: '/skuPayForJifen', component: SkuPayForJifen },
         { path: '/newKill', component: NewKill },
        ]
      },
      { path: '/test', component: test },
      { path: '/productDetailOne', component: ProductDetailOne },
    ]

  },
]

const router = new VueRouter({
  routes
})

export default router
